package com.study.spmongodb.wwj.thread3.char01;

/**
 * @author study
 * @version 1.0
 * @date 2020/12/10 14:10
 * https://www.bilibili.com/video/BV1hJ411D7k2?p=83
 */
public class Singleton {
    public static int x = 0;
    public static int y;
    private static Singleton singleton = new Singleton();

    // 位置不一样结果 不同。
    //private static Singleton singleton = new Singleton();
    private Singleton() {
        y++;
        x++;
    }

    public static Singleton getSingleton() {
        return singleton;
    }

    public static void main(String[] args) {
        final Singleton singleton = getSingleton();

        System.out.println(singleton.x);
        System.out.println(singleton.y);
    }

}
